<script setup>
import { defineProps } from 'vue'

const props = defineProps({
  report: {
    type: Object,
    required: true
  }
})

const emit = defineEmits(['generate-report'])
</script>

<template>
  <div class="analysis-report-card">
    <div class="card-header">
      <h2><i class="fas fa-file-alt"></i> 故障分析报告</h2>

      <el-button
          type="primary"
          :loading="report.loading"
          @click="emit('generate-report')"
          :disabled="report.generated"
      >
        <i class="fas fa-robot"></i> {{ report.generated ? '已生成' : '生成AI报告' }}
      </el-button>
    </div>

    <div v-if="report.generated" class="report-content">
      <div class="report-html" v-html="report.content"></div>
    </div>

    <div v-else class="report-placeholder">
      <i class="fas fa-file-medical"></i>
      <p>点击"生成AI报告"按钮，系统将使用LLM+RAG技术生成详细故障分析报告</p>
      <p>报告将包含故障原因分析、可能性评估和详细维修建议</p>
    </div>
  </div>
</template>

<style scoped>
.analysis-report-card {
  background: linear-gradient(135deg, #1a2a52, #152245);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  border: 1px solid #2a3a6a;
  height: 100%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #2a3a6a;
}

.card-header h2 {
  font-size: 18px;
  color: #e4e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-content {
  background: rgba(10, 25, 55, 0.7);
  border-radius: 8px;
  padding: 20px;
  height: calc(100% - 60px);
  overflow-y: auto;
}

.report-html {
  color: #e4e8f0;
  line-height: 1.8;
}

.report-html h2 {
  font-size: 22px;
  color: #ff7e5f;
  margin: 20px 0 15px;
  border-bottom: 1px solid #2a3a6a;
  padding-bottom: 8px;
}

.report-html h3 {
  font-size: 18px;
  color: #feb47b;
  margin: 15px 0 10px;
}

.report-html p {
  margin: 10px 0;
}

.report-html ul {
  padding-left: 25px;
  margin: 10px 0;
}

.report-html li {
  margin: 8px 0;
}

.report-placeholder {
  height: calc(100% - 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #a0b1d0;
  padding: 30px;
}

.report-placeholder i {
  font-size: 60px;
  color: #4facfe;
  margin-bottom: 20px;
}

.report-placeholder p {
  margin: 10px 0;
  max-width: 400px;
}
</style>